package com.yun.algorithmproblem.huaweiod;

import java.util.Arrays;
import java.util.Scanner;

public class HJ17 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        String s = in.nextLine();
        System.out.println(s);
        int[] res=coordinate(s);
        System.out.println(res[0]+","+res[1]);
    }

    static int[] coordinate(String s) {
        int[] xy = new int[2];
        String[] parts = s.split(";");
        System.out.println(Arrays.toString(parts));
        for (String part : parts) {
            if (part.length() == 2 || part.length() == 3) {
                char[] chars=part.toCharArray();
                boolean isNumber=true;
                int number=0;
                for (int i = 1; i < chars.length; i++) {
                    if (!('0' <= chars[i] && chars[i] <= '9')) {
                        isNumber = false;
                        break;
                    }
                    number=number*10+chars[i]-'0';
                }
                if (isNumber) {
                    switch (chars[0]) {
                        case 'A' -> xy[0] -= number;
                        case 'D' -> xy[0] += number;
                        case 'W' -> xy[1] += number;
                        case 'S' -> xy[1] -= number;
                        default -> {
                        }
                    }
                }
            }
        }
        return xy;
    }
}
